package business;

import java.util.ArrayList;
import model.FacilityDTO;
import dao.DAOException;
import dao.DAOFactory;
import dao.FacilityDAO;

public class FacilityManager {
	
	private FacilityDAO facilityDAO;
	
	public FacilityManager()
	{
		facilityDAO = DAOFactory.loadInstance().getFacilityDAO();
	}
	public void insertFacility(FacilityDTO facility) 
	{
		try
		{
			facilityDAO.insertFacility(facility);
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
	}
	public void updateFacility(FacilityDTO facility) 
	{
		try
		{
			facilityDAO.updateFacility(facility);
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
	}
	public void deleteFacility(FacilityDTO facility)
	{
		try
		{
			facilityDAO.deleteFacility(facility);
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
	}
	@SuppressWarnings("finally")
	public ArrayList<FacilityDTO> findAllFacility()
	{
		ArrayList<FacilityDTO> currentList = new ArrayList<FacilityDTO>();
		try
		{
			currentList = facilityDAO.findAllFacility();
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			return currentList;
		}
	}
	@SuppressWarnings("finally")
	public FacilityDTO findFacility(int facilityID) 
	{
		FacilityDTO currentfacility = new FacilityDTO();
		try
		{
			currentfacility = facilityDAO.findFacility(facilityID);
		}
		catch(DAOException e)
		{
			e.printStackTrace();
		}
		finally
		{
			return currentfacility;
		}
	}
}
